declare namespace pm = "http://www.politicalmashup.nl"; 
declare option exist:serialize "doctype-public=-//W3C//DTD&#160;XHTML&#160;1.1//EN
                                doctype-system=http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";
                    
import module namespace layout="http://www.example.com/layout" at "xmldb:exist:///db/projdb/modules/layout.xqm";        
                    


declare variable $onderbrokeneID {xs:string(request:get-parameter("onderbrokeneID", ()))};
declare variable $onderbrekerID {xs:string(request:get-parameter("onderbrekerID", ()))};
declare function local:getNaam($individualID){
    data(doc('/db/projdb/participatie_parameters_ge2009.xml')/result/tupel[@ref=$individualID]/speaker)
};

declare variable $onderbrokeneNaam { local:getNaam($onderbrokeneID)};
declare variable $onderbrekerNaam { local:getNaam($onderbrekerID)};

declare variable $entries {doc('/db/projdb/onderbrekersdata.xml')/onderbrekersdata/entry[data(./onderbreker) = $onderbrekerNaam and data(./onderbrokene) = $onderbrokeneNaam]};

declare variable $speeches {collection('/db/projdb/ge-2009')//pm:speech};
(: declare variable $temp {<ul>{ for $i in $entries return concat(<li> {data($speeches[./@pm:id = $onderbreker])}</li>,<li>{data($speeches[./@pm:id = $onderbrokene])}</li>)}</ul>};:)

declare function local:getTekst($id){
  $speeches[data(./@pm:id) = $id]
};
declare variable $data {for $i at $position in $entries let $e := local:getTekst($i/onderbmid) return <div class="boxContent" style="margin-top:{if($position = 1) then '0' else '10'}px"><div class="columnspace darkBackground"><div class="column"><h3 class="columnTitle">Onderbrokene:</h3><div style="margin-left:10px;margin-right:10px"> {data($e)}</div><h3 class="columnTitle">Onderbreker:</h3><div style="margin-left:10px;margin-right:10px">{data($e/following-sibling::pm:speech[1])}</div></div><br class="clearer"/></div></div>};
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Activiteit in de plenaire vergaderingen</title>
        <link rel="stylesheet" style="text/css" href="style/core_layout.css"/>
		<script type="text/javascript" src="js/jquery.js"><!-- --></script>
        <script type="text/javascript" src="https://www.google.com/jsapi"><!-- --></script>
        <script type="text/javascript" src="js/activity.js"><!-- --></script>
        <script type="text/javascript" src="js/myScripts.js"><!-- --></script>
    </head>
    <body>
            <div class="containerBox">
  
        {layout:topMenu()}
    <div class="box" id="titleBox">
                <div class="margin">
                    <h1>Data: {$onderbrekerNaam} onderbreekt {$onderbrokeneNaam}</h1>
                </div>
            </div>
     <div class="box" id="partyQuartileChartBox">
            <div class="margin" style="margin-top:0px">
                    {$data}
            </div>
     </div>
    
    </div>
    </body>
   
</html>
